<?php

class OrganizationalPropertyFactory
{
  
  private static $instance = null;

  private function __construct ()
  {
  
  }

  /**
   * @return OrganizationalPropertyFactory
   */
  public static function getInstance ()
  {
    if (is_null(self::$instance))
    {
      self::$instance = new self();
    }
    return self::$instance;
  }

  public function create (OrganizationalUnit $unit, OrganizationalProperty $property, OrganizationalPropertyType $type, $value)
  {
    $type_class = $type->getClass();
    if (is_null($type_class))
    {
      $type_class = 'DefaultOrganizationalPropertyType';
    }
    $type_obj = new $type_class($unit);
    return new ValuedOrganizationalProperty($unit, $property, $type_obj, $value);
  }
}